﻿// Genius
// Copyright (C) 2016 Dirk Friedenberger, www.frittenburger.de
//   
// This source file is subject to the Microsoft Public License (Ms-PL).
// http://www.opensource.org/licenses/ms-pl.html
// All other rights reserved.
using Genius.Brain.Shared.BO;
using Genius.Brain.Shared.Strategy;
using Genius.Locator.Internal;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Genius.Brain.Shared.Locator
{
    public class BrainLocator
    {

      

        public static IGenius GetGenius(string id, string name)
        {
            IGenius genius = ContainerHolder.Resolve<IGenius>();
            genius.Id = id;
            genius.Name = name;
            genius.Channels = new List<IChannel>();
            genius.IMs = new List<IInstantMessaging>();
            genius.Modules = new List<IGeniusModule>();
            return genius;
        }

        public static ILanguageConstructorStrategy GetLanguageConstructorStrategy(string language)
        {
            return ContainerHolder.Resolve<ILanguageConstructorStrategy>(language);
        }

        public static ITokenDatabaseRecord GetTokenDatabaseRecord()
        {
            return ContainerHolder.Resolve<ITokenDatabaseRecord>();
        }

        public static IJsonDatabase<ITokenDatabaseRecord> GetTokenDatabase()
        {
            return ContainerHolder.Resolve<IJsonDatabase<ITokenDatabaseRecord>>();
        }

        public static IMessage GetMessage()
        {
            return ContainerHolder.Resolve<IMessage>();
        }

        public static IDialog GetDialog()
        {
            return ContainerHolder.Resolve<IDialog>();
        }

        public static IChannel GetChannel()
        {
            return ContainerHolder.Resolve<IChannel>();
        }

        public static IGeniusModule GetGeniusModule(string name)
        {
            return ContainerHolder.Resolve<IGeniusModule>(name);
        }

        public static IInstantMessaging GetIM()
        {
            return ContainerHolder.Resolve<IInstantMessaging>();
        }

      
        public static ITextParserStrategy GetTextParserStrategy(string[] fileNames)
        {
            return ContainerHolder.Resolve<ITextParserStrategy>(new { fileNames = fileNames });
        }

        public static ITextParserStrategy GetTextParserStrategy(string fileName)
        {
            return GetTextParserStrategy(new string[] { fileName });
        }

        public static ITextFormaterStrategy GetTextFormaterStrategy(string[] fileNames)
        {
            return ContainerHolder.Resolve<ITextFormaterStrategy>(new { fileNames = fileNames });
        }
        public static ITextFormaterStrategy GetTextFormaterStrategy(string fileName)
        {
            return GetTextFormaterStrategy(new string[] { fileName });
        }

        public static ITextTokenizerStrategy GetTextTokenizerStrategy()
        {
            return ContainerHolder.Resolve<ITextTokenizerStrategy>();
        }

        public static IDialogContext GetDialogContext()
        {
            return ContainerHolder.Resolve<IDialogContext>();
        }

        public static ITextMatcherStrategy GetTextMatcherStrategy()
        {
            return ContainerHolder.Resolve<ITextMatcherStrategy>();
        }

        public static ITextToken GetTextToken(string type, string data)
        {
            var token = ContainerHolder.Resolve<ITextToken>();
            token.Type = type;
            token.Data = data;
            return token;
        }

        public static IMatch GetMatch()
        {
            return ContainerHolder.Resolve<IMatch>();
        }

        public static IText GetText(string token, string language)
        {
            var text = ContainerHolder.Resolve<IText>();

            text.Original = "";
            text.Params = new Dictionary<string, string>();
            text.Token = token;
            text.Language = language;

            return text;
        }

    }
}
